home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / VBASIC / T2WIN-32.ZIP / _BITSTR.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-01-01  |  30.7 KB  |  752 lines

  1. VERSION 4.00
  2. Begin VB.Form frmBitString 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Bit string"
  5.    ClientHeight    =   4035
  6.    ClientLeft      =   870
  7.    ClientTop       =   2115
  8.    ClientWidth     =   9885
  9.    Height          =   4440
  10.    Left            =   810
  11.    MaxButton       =   0   'False
  12.    MDIChild        =   -1  'True
  13.    ScaleHeight     =   4035
  14.    ScaleWidth      =   9885
  15.    ShowInTaskbar   =   0   'False
  16.    Top             =   1770
  17.    Width           =   10005
  18.    Begin VB.TextBox txt_Result 
  19.       BackColor       =   &H00C0C0C0&
  20.       BorderStyle     =   0  'None
  21.       Height          =   2895
  22.       Left            =   90
  23.       Locked          =   -1  'True
  24.       MultiLine       =   -1  'True
  25.       ScrollBars      =   2  'Vertical
  26.       TabIndex        =   10
  27.       Top             =   540
  28.       Width           =   9645
  29.    End
  30.    Begin Threed.SSPanel SSPanel2 
  31.       Align           =   2  'Align Bottom
  32.       Height          =   465
  33.       Left            =   0
  34.       TabIndex        =   0
  35.       Top             =   3570
  36.       Width           =   9885
  37.       _Version        =   65536
  38.       _ExtentX        =   17436
  39.       _ExtentY        =   820
  40.       _StockProps     =   15
  41.       BackColor       =   12632256
  42.       Begin VB.TextBox Text1 
  43.          Height          =   285
  44.          Left            =   1440
  45.          TabIndex        =   2
  46.          Tag             =   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  47.          Top             =   90
  48.          Width           =   7485
  49.       End
  50.       Begin Threed.SSCommand SSCommand2 
  51.          Height          =   285
  52.          Left            =   9000
  53.          TabIndex        =   3
  54.          Top             =   90
  55.          Width           =   825
  56.          _Version        =   65536
  57.          _ExtentX        =   1455
  58.          _ExtentY        =   503
  59.          _StockProps     =   78
  60.          Caption         =   "&Reset"
  61.          BevelWidth      =   1
  62.          Outline         =   0   'False
  63.       End
  64.       Begin VB.Label Label1 
  65.          Caption         =   "&Enter a test string"
  66.          Height          =   255
  67.          Left            =   90
  68.          TabIndex        =   1
  69.          Top             =   120
  70.          Width           =   1275
  71.       End
  72.    End
  73.    Begin Threed.SSPanel SSPanel1 
  74.       Align           =   1  'Align Top
  75.       Height          =   480
  76.       Left            =   0
  77.       TabIndex        =   4
  78.       Top             =   0
  79.       Width           =   9885
  80.       _Version        =   65536
  81.       _ExtentX        =   17436
  82.       _ExtentY        =   847
  83.       _StockProps     =   15
  84.       ForeColor       =   -2147483640
  85.       BackColor       =   12632256
  86.       Begin VB.ComboBox cmb_Function 
  87.          Height          =   315
  88.          Left            =   1365
  89.          TabIndex        =   5
  90.          Top             =   75
  91.          Width           =   7305
  92.       End
  93.       Begin Threed.SSCommand cmdNP 
  94.          Height          =   300
  95.          Index           =   1
  96.          Left            =   9570
  97.          TabIndex        =   9
  98.          Top             =   90
  99.          Width           =   255
  100.          _Version        =   65536
  101.          _ExtentX        =   450
  102.          _ExtentY        =   529
  103.          _StockProps     =   78
  104.          Caption         =   ">"
  105.          BevelWidth      =   1
  106.          Font3D          =   3
  107.          RoundedCorners  =   0   'False
  108.          Outline         =   0   'False
  109.       End
  110.       Begin Threed.SSCommand cmdNP 
  111.          Height          =   300
  112.          Index           =   0
  113.          Left            =   8730
  114.          TabIndex        =   8
  115.          Top             =   90
  116.          Width           =   255
  117.          _Version        =   65536
  118.          _ExtentX        =   450
  119.          _ExtentY        =   529
  120.          _StockProps     =   78
  121.          Caption         =   "<"
  122.          BevelWidth      =   1
  123.          Font3D          =   3
  124.          RoundedCorners  =   0   'False
  125.          Outline         =   0   'False
  126.       End
  127.       Begin VB.Label Label2 
  128.          Caption         =   "&Select a function"
  129.          Height          =   255
  130.          Left            =   90
  131.          TabIndex        =   7
  132.          Top             =   120
  133.          Width           =   1275
  134.       End
  135.       Begin Threed.SSCommand SSCommand1 
  136.          Default         =   -1  'True
  137.          Height          =   300
  138.          Left            =   9045
  139.          TabIndex        =   6
  140.          Top             =   90
  141.          Width           =   465
  142.          _Version        =   65536
  143.          _ExtentX        =   820
  144.          _ExtentY        =   529
  145.          _StockProps     =   78
  146.          Caption         =   "&Go"
  147.          BevelWidth      =   1
  148.          RoundedCorners  =   0   'False
  149.          Outline         =   0   'False
  150.       End
  151.    End
  152. Attribute VB_Name = "frmBitString"
  153. Attribute VB_Creatable = False
  154. Attribute VB_Exposed = False
  155. Option Explicit
  156. Option Base 1
  157. Private Const Iteration = 250
  158. Dim IsLoaded         As Integer
  159. Dim TimerStartOk     As Integer
  160. Dim TimerCloseOk     As Integer
  161. Dim TimerHandle      As Integer
  162. Dim TimerValue       As Long
  163. Private Sub cmb_Function_Click()
  164.    If (IsLoaded = False) Then Exit Sub
  165.    Call cDisableFI(mdiT2W.Picture1)
  166.    SSPanel2.Visible = True
  167.    txt_Result = ""
  168.    DoEvents
  169.    Select Case cmb_Function.ListIndex
  170.       Case 0
  171.          SSPanel2.Visible = False
  172.          Call TestCreateBits
  173.       Case 1
  174.          Call TestFindBitReset
  175.       Case 2
  176.          Call TestFindBitSet
  177.       Case 3
  178.          Call TestGetBit
  179.       Case 4
  180.          SSPanel2.Visible = False
  181.          Call TestGiveBitPalindrome
  182.       Case 5
  183.          Call TestIsBitPalindrome
  184.       Case 6
  185.          Call TestReverseAllBits
  186.       Case 7
  187.          Call TestReverseAllBitsByChar
  188.       Case 8
  189.          Call TestSetAllBits
  190.       Case 9
  191.          Call TestSetBit
  192.       Case 10
  193.          Call TestToggleAllBits
  194.       Case 11
  195.          Call TestToggleBit
  196.       Case 12
  197.          SSPanel2.Visible = False
  198.          Call TestGetBitValue
  199.       Case 13
  200.          SSPanel2.Visible = False
  201.          Call TestSetBitValue
  202.       Case 14
  203.          SSPanel2.Visible = False
  204.          TestB2I
  205.    End Select
  206.    DoEvents
  207.    Call cEnableFI(mdiT2W.Picture1)
  208. End Sub
  209. Private Sub cmdNP_Click(Index As Integer)
  210.    Call sub_NextPrev(cmb_Function, Index)
  211. End Sub
  212. Private Sub Form_Activate()
  213.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  214. End Sub
  215. Private Sub Form_Load()
  216.    IsLoaded = False
  217.    Show
  218.    Text1.Text = Text1.Tag + LCase$(Text1.Tag)
  219.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_bitstr.t2w")
  220.    IsLoaded = True
  221. End Sub
  222. Private Sub SSCommand1_Click()
  223.    Call cmb_Function_Click
  224. End Sub
  225. Private Sub TestCreateBits()
  226.    Dim intResult        As Integer
  227.    Dim strResult        As String
  228.    Dim strDisplay       As String
  229.    Dim i                As Integer
  230.    intResult = 0
  231.    strResult = ""
  232.    strDisplay = ""
  233.      
  234.    strResult = cCreateBits(1024)
  235.    strDisplay = strDisplay + "Create a bit string for 1024 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
  236.    strResult = cCreateBits(512)
  237.    strDisplay = strDisplay + "Create a bit string for 512 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
  238.    strResult = cCreateBits(33)
  239.    strDisplay = strDisplay + "Create a bit string for 33 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
  240.    strResult = cCreateBits(1)
  241.    strDisplay = strDisplay + "Create a bit string for 1 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
  242.    strResult = cCreateBits(-1)
  243.    strDisplay = strDisplay + "Create a bit string for -1 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
  244.    txt_Result = strDisplay
  245.    'time the function
  246.    TimerHandle = cTimerOpen()
  247.    TimerStartOk = cTimerStart(TimerHandle)
  248.    For i = 1 To Iteration
  249.       strResult = cCreateBits(1024)
  250.    Next i
  251.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  252.    TimerCloseOk = cTimerClose(TimerHandle)
  253. End Sub
  254. Private Sub TestFindBitReset()
  255.    Dim intResult        As Integer
  256.    Dim strResult        As String
  257.    Dim strDisplay       As String
  258.    Dim strData          As String
  259.    Dim i                As Integer
  260.    intResult = 0
  261.    strResult = ""
  262.    strDisplay = ""
  263.      
  264.    strData = Text1.Text
  265.    strDisplay = strDisplay + "The following bits are Reset (False) " & vbCrLf & vbCrLf
  266.    intResult = True
  267.    Do
  268.       intResult = cFindBitReset(strData, intResult)
  269.       If (intResult <> True) Then strDisplay = strDisplay & intResult & ", "
  270.    Loop Until (intResult = True)
  271.    strDisplay = Left$(strDisplay, Len(strDisplay) - 1)
  272.    strDisplay = strDisplay & vbCrLf & vbCrLf
  273.    txt_Result = strDisplay
  274.    'time the function
  275.    TimerHandle = cTimerOpen()
  276.    TimerStartOk = cTimerStart(TimerHandle)
  277.    For i = 1 To Iteration
  278.       intResult = cFindBitReset(strData, i)
  279.    Next i
  280.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  281.    TimerCloseOk = cTimerClose(TimerHandle)
  282. End Sub
  283. Private Sub SSCommand2_Click()
  284.    Text1.Text = Text1.Tag + LCase$(Text1.Tag)
  285.    Call SSCommand1_Click
  286. End Sub
  287. Private Sub TestFindBitSet()
  288.    Dim intResult        As Integer
  289.    Dim strResult        As String
  290.    Dim strDisplay       As String
  291.    Dim strData          As String
  292.    Dim i                As Integer
  293.    intResult = 0
  294.    strResult = ""
  295.    strDisplay = ""
  296.      
  297.    strData = Text1.Text
  298.    strDisplay = strDisplay + "The following bits are Set (True) " & vbCrLf & vbCrLf
  299.    intResult = True
  300.    Do
  301.       intResult = cFindBitSet(strData, intResult)
  302.       If (intResult <> True) Then strDisplay = strDisplay & intResult & ", "
  303.    Loop Until (intResult = True)
  304.    strDisplay = Left$(strDisplay, Len(strDisplay) - 1)
  305.    strDisplay = strDisplay & vbCrLf & vbCrLf
  306.    txt_Result = strDisplay
  307.    'time the function
  308.    TimerHandle = cTimerOpen()
  309.    TimerStartOk = cTimerStart(TimerHandle)
  310.    For i = 1 To Iteration
  311.       intResult = cFindBitSet(strData, i)
  312.    Next i
  313.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  314.    TimerCloseOk = cTimerClose(TimerHandle)
  315. End Sub
  316. Private Sub TestGetBit()
  317.    Dim intResult        As Integer
  318.    Dim strResult        As String
  319.    Dim strDisplay       As String
  320.    Dim strData          As String
  321.    Dim i                As Integer
  322.    intResult = 0
  323.    strResult = ""
  324.    strDisplay = ""
  325.      
  326.    strData = Text1.Text
  327.    strDisplay = strDisplay + "Bit '1' is '" & IIf(cGetBit(strData, 1), "set", "reset") & "'" & vbCrLf
  328.    strDisplay = strDisplay + "Bit '3' is '" & IIf(cGetBit(strData, 3), "set", "reset") & "'" & vbCrLf
  329.    strDisplay = strDisplay + "Bit '5' is '" & IIf(cGetBit(strData, 5), "set", "reset") & "'" & vbCrLf
  330.    strDisplay = strDisplay + "Bit '7' is '" & IIf(cGetBit(strData, 7), "set", "reset") & "'" & vbCrLf
  331.    strDisplay = strDisplay + "Bit '100' is '" & IIf(cGetBit(strData, 100), "set", "reset") & "'" & vbCrLf
  332.    strDisplay = strDisplay + "Bit '102' is '" & IIf(cGetBit(strData, 102), "set", "reset") & "'" & vbCrLf
  333.    strDisplay = strDisplay + "Bit '104' is '" & IIf(cGetBit(strData, 104), "set", "reset") & "'" & vbCrLf
  334.    strDisplay = strDisplay + "Bit '106' is '" & IIf(cGetBit(strData, 106), "set", "reset") & "'" & vbCrLf
  335.    txt_Result = strDisplay
  336.    'time the function
  337.    TimerHandle = cTimerOpen()
  338.    TimerStartOk = cTimerStart(TimerHandle)
  339.    For i = 1 To Iteration
  340.       intResult = cGetBit(strData, i)
  341.    Next i
  342.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  343.    TimerCloseOk = cTimerClose(TimerHandle)
  344. End Sub
  345. Private Sub TestGiveBitPalindrome()
  346.    Dim intResult        As Integer
  347.    Dim strResult        As String
  348.    Dim strDisplay       As String
  349.    Dim strData          As String
  350.    Dim i                As Integer
  351.    intResult = 0
  352.    strResult = ""
  353.    strDisplay = ""
  354.      
  355.    strResult = cGiveBitPalindrome()
  356.    strDisplay = strDisplay + "The followings chars are Bit Palindrome : " & vbCrLf & vbCrLf
  357.    strDisplay = strDisplay + "chr(0) and  " & cBlockCharFromRight(cGiveBitPalindrome(), 1)
  358.    txt_Result = strDisplay
  359.    'time the function
  360.    TimerHandle = cTimerOpen()
  361.    TimerStartOk = cTimerStart(TimerHandle)
  362.    For i = 1 To Iteration
  363.       strResult = cGiveBitPalindrome()
  364.    Next i
  365.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  366.    TimerCloseOk = cTimerClose(TimerHandle)
  367. End Sub
  368. Private Sub TestIsBitPalindrome()
  369.    Dim intResult        As Integer
  370.    Dim strResult        As String
  371.    Dim strDisplay       As String
  372.    Dim strData          As String
  373.    Dim i                As Integer
  374.    intResult = 0
  375.    strResult = ""
  376.    strDisplay = ""
  377.    strData = Text1.Text
  378.      
  379.    intResult = cIsBitPalindrome(strData)
  380.    strDisplay = strDisplay + "Test string is " & IIf(intResult, "", "not ") & "Bit Palindrome " & vbCrLf & vbCrLf
  381.    strDisplay = strDisplay + "The followings chars are Bit Palindrome : " & vbCrLf
  382.    For i = 1 To 255
  383.       If cIsBitPalindrome(Chr$(i)) Then strDisplay = strDisplay + Chr$(i) & " (" & i & ") "
  384.    Next i
  385.    txt_Result = strDisplay
  386.    'time the function
  387.    TimerHandle = cTimerOpen()
  388.    TimerStartOk = cTimerStart(TimerHandle)
  389.    For i = 1 To Iteration
  390.       intResult = cIsBitPalindrome(strData)
  391.    Next i
  392.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  393.    TimerCloseOk = cTimerClose(TimerHandle)
  394. End Sub
  395. Private Sub TestReverseAllBits()
  396.    Dim intResult        As Integer
  397.    Dim strResult        As String
  398.    Dim strDisplay       As String
  399.    Dim strData          As String
  400.    Dim i                As Integer
  401.    intResult = 0
  402.    strResult = ""
  403.    strDisplay = ""
  404.    strData = Text1.Text
  405.      
  406.    Call cReverseAllBits(strData)
  407.    strDisplay = strDisplay + "Reverse all bits is " & vbCrLf & strData & vbCrLf & vbCrLf
  408.    Call cReverseAllBits(strData)
  409.    strDisplay = strDisplay + "Reverse all bits of the reversed is " & vbCrLf & strData & vbCrLf & vbCrLf
  410.    txt_Result = strDisplay
  411.    'time the function
  412.    TimerHandle = cTimerOpen()
  413.    TimerStartOk = cTimerStart(TimerHandle)
  414.    For i = 1 To Iteration
  415.       Call cReverseAllBits(strData)
  416.    Next i
  417.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  418.    TimerCloseOk = cTimerClose(TimerHandle)
  419. End Sub
  420. Private Sub TestReverseAllBitsByChar()
  421.    Dim intResult        As Integer
  422.    Dim strResult        As String
  423.    Dim strDisplay       As String
  424.    Dim strData          As String
  425.    Dim i                As Integer
  426.    intResult = 0
  427.    strResult = ""
  428.    strDisplay = ""
  429.    strData = Text1.Text
  430.      
  431.    Call cReverseAllBitsByChar(strData)
  432.    strDisplay = strDisplay + "Reverse all bits by char is " & vbCrLf & strData & vbCrLf & vbCrLf
  433.    Call cReverseAllBitsByChar(strData)
  434.    strDisplay = strDisplay + "Reverse all bits by char of the reversed is " & vbCrLf & strData & vbCrLf & vbCrLf
  435.    txt_Result = strDisplay
  436.    'time the function
  437.    TimerHandle = cTimerOpen()
  438.    TimerStartOk = cTimerStart(TimerHandle)
  439.    For i = 1 To Iteration
  440.       Call cReverseAllBitsByChar(strData)
  441.    Next i
  442.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  443.    TimerCloseOk = cTimerClose(TimerHandle)
  444. End Sub
  445. Private Sub TestSetAllBits()
  446.    Dim intResult        As Integer
  447.    Dim strResult        As String
  448.    Dim strDisplay       As String
  449.    Dim strData          As String
  450.    Dim i                As Integer
  451.    intResult = 0
  452.    strResult = ""
  453.    strDisplay = ""
  454.    strData = Text1.Text
  455.    Call cSetAllBits(strData, True)
  456.    strDisplay = strDisplay + "Set all bits is " & vbCrLf
  457.    strDisplay = strDisplay + strData & vbCrLf & vbCrLf
  458.    Call cSetAllBits(strData, False)
  459.    strDisplay = strDisplay + "Reset all bits is " & vbCrLf
  460.    strDisplay = strDisplay + strData & vbCrLf & vbCrLf
  461.    txt_Result = strDisplay
  462.    'time the function
  463.    TimerHandle = cTimerOpen()
  464.    TimerStartOk = cTimerStart(TimerHandle)
  465.    For i = 1 To Iteration
  466.       Call cSetAllBits(strData, True)
  467.    Next i
  468.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  469.    TimerCloseOk = cTimerClose(TimerHandle)
  470. End Sub
  471. Private Sub TestSetBit()
  472.    Dim intResult        As Integer
  473.    Dim strResult        As String
  474.    Dim strDisplay       As String
  475.    Dim strData          As String
  476.    Dim i                As Integer
  477.    intResult = 0
  478.    strResult = ""
  479.    strDisplay = ""
  480.    strData = Text1.Text
  481.    Call cSetBit(strData, 0, True)
  482.    strDisplay = strDisplay + "Set bit '0' is '" & strData & "'" & vbCrLf
  483.    Call cSetBit(strData, 5, True)
  484.    strDisplay = strDisplay + "Set bit '5' is '" & strData & "'" & vbCrLf
  485.    Call cSetBit(strData, 7, True)
  486.    strDisplay = strDisplay + "Set bit '7' is '" & strData & "'" & vbCrLf & vbCrLf
  487.    Call cSetBit(strData, 0, False)
  488.    strDisplay = strDisplay + "Reset bit '0' is '" & strData & "'" & vbCrLf
  489.    Call cSetBit(strData, 5, False)
  490.    strDisplay = strDisplay + "Reset bit '5' is '" & strData & "'" & vbCrLf
  491.    Call cSetBit(strData, 7, False)
  492.    strDisplay = strDisplay + "Reset bit '7' is '" & strData & "'" & vbCrLf & vbCrLf
  493.    Call cSetBit(strData, 22, True)
  494.    strDisplay = strDisplay + "Set bit '22' is '" & strData & "'" & vbCrLf
  495.    Call cSetBit(strData, 30, True)
  496.    strDisplay = strDisplay + "Set bit '30' is '" & strData & "'" & vbCrLf
  497.    Call cSetBit(strData, 38, True)
  498.    strDisplay = strDisplay + "Set bit '38' is '" & strData & "'" & vbCrLf & vbCrLf
  499.    Call cSetBit(strData, 22, False)
  500.    strDisplay = strDisplay + "Reset bit '22' is '" & strData & "'" & vbCrLf
  501.    Call cSetBit(strData, 30, False)
  502.    strDisplay = strDisplay + "Reset bit '30' is '" & strData & "'" & vbCrLf
  503.    Call cSetBit(strData, 38, False)
  504.    strDisplay = strDisplay + "Reset bit '38' is '" & strData & "'" & vbCrLf & vbCrLf
  505.    txt_Result = strDisplay
  506.    'time the function
  507.    TimerHandle = cTimerOpen()
  508.    TimerStartOk = cTimerStart(TimerHandle)
  509.    For i = 1 To Iteration
  510.       Call cSetBit(strData, 0, True)
  511.    Next i
  512.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  513.    TimerCloseOk = cTimerClose(TimerHandle)
  514. End Sub
  515. Private Sub TestToggleAllBits()
  516.    Dim intResult        As Integer
  517.    Dim strResult        As String
  518.    Dim strDisplay       As String
  519.    Dim strData          As String
  520.    Dim i                As Integer
  521.    intResult = 0
  522.    strResult = ""
  523.    strDisplay = ""
  524.    strData = Text1.Text
  525.    Call cToggleAllBits(strData)
  526.    strDisplay = strDisplay + "Toggle all bits is " & vbCrLf
  527.    strDisplay = strDisplay + strData & vbCrLf & vbCrLf
  528.    Call cToggleAllBits(strData)
  529.    strDisplay = strDisplay + "Toggle all bits of the toggled is " & vbCrLf
  530.    strDisplay = strDisplay + strData & vbCrLf & vbCrLf
  531.    txt_Result = strDisplay
  532.    'time the function
  533.    TimerHandle = cTimerOpen()
  534.    TimerStartOk = cTimerStart(TimerHandle)
  535.    For i = 1 To Iteration
  536.       Call cToggleAllBits(strData)
  537.    Next i
  538.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  539.    TimerCloseOk = cTimerClose(TimerHandle)
  540. End Sub
  541. Private Sub TestToggleBit()
  542.    Dim intResult        As Integer
  543.    Dim strResult        As String
  544.    Dim strDisplay       As String
  545.    Dim strData          As String
  546.    Dim i                As Integer
  547.    intResult = 0
  548.    strResult = ""
  549.    strDisplay = ""
  550.    strData = Text1.Text
  551.    Call cToggleBit(strData, 0)
  552.    strDisplay = strDisplay + "Toggle bit '0' is '" & strData & "'" & vbCrLf
  553.    Call cToggleBit(strData, 5)
  554.    strDisplay = strDisplay + "Toggle bit '5' is '" & strData & "'" & vbCrLf
  555.    Call cToggleBit(strData, 7)
  556.    strDisplay = strDisplay + "Toggle bit '7' is '" & strData & "'" & vbCrLf & vbCrLf
  557.    Call cToggleBit(strData, 0)
  558.    strDisplay = strDisplay + "Toggle bit '0' is '" & strData & "'" & vbCrLf
  559.    Call cToggleBit(strData, 5)
  560.    strDisplay = strDisplay + "Toggle bit '5' is '" & strData & "'" & vbCrLf
  561.    Call cToggleBit(strData, 7)
  562.    strDisplay = strDisplay + "Toggle bit '7' is '" & strData & "'" & vbCrLf & vbCrLf
  563.    Call cToggleBit(strData, 22)
  564.    strDisplay = strDisplay + "Toggle bit '22' is '" & strData & "'" & vbCrLf
  565.    Call cToggleBit(strData, 30)
  566.    strDisplay = strDisplay + "Toggle bit '30' is '" & strData & "'" & vbCrLf
  567.    Call cToggleBit(strData, 38)
  568.    strDisplay = strDisplay + "Toggle bit '38' is '" & strData & "'" & vbCrLf & vbCrLf
  569.    Call cToggleBit(strData, 22)
  570.    strDisplay = strDisplay + "Toggle bit '22' is '" & strData & "'" & vbCrLf
  571.    Call cToggleBit(strData, 30)
  572.    strDisplay = strDisplay + "Toggle bit '30' is '" & strData & "'" & vbCrLf
  573.    Call cToggleBit(strData, 38)
  574.    strDisplay = strDisplay + "Toggle bit '38' is '" & strData & "'" & vbCrLf & vbCrLf
  575.    txt_Result = strDisplay
  576.    'time the function
  577.    TimerHandle = cTimerOpen()
  578.    TimerStartOk = cTimerStart(TimerHandle)
  579.    For i = 1 To Iteration
  580.       Call cToggleBit(strData, 0)
  581.    Next i
  582.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  583.    TimerCloseOk = cTimerClose(TimerHandle)
  584. End Sub
  585. Private Sub TestGetBitValue()
  586.    Dim intResult        As Integer
  587.    Dim strResult        As String
  588.    Dim strDisplay       As String
  589.    Dim bData            As Byte
  590.    Dim iData            As Integer
  591.    Dim lData            As Long
  592.    Dim sData            As Single
  593.    Dim dData            As Double
  594.    Dim i                As Integer
  595.    intResult = 0
  596.    strResult = ""
  597.    strDisplay = ""
  598.    Call cRndInit(-1)
  599.    bData = (Abs(cRndI()) Mod 256)
  600.    iData = Abs(cRndI())
  601.    lData = Abs(cRndL())
  602.    sData = Abs(cRndS())
  603.    dData = Abs(cRndD())
  604.      
  605.    strDisplay = strDisplay + "Byte value : " & bData & " (" & cToBinary(cMKB(bData)) & ")" & vbCrLf
  606.    strDisplay = strDisplay + "   bit 0 is " & IIf(cGetBitB(bData, 0), "set", "reset") & vbCrLf
  607.    strDisplay = strDisplay + "   bit 1 is " & IIf(cGetBitB(bData, 1), "set", "reset") & vbCrLf
  608.    strDisplay = strDisplay + "   bit 3 is " & IIf(cGetBitB(bData, 3), "set", "reset") & vbCrLf
  609.    strDisplay = strDisplay + "   bit 5 is " & IIf(cGetBitB(bData, 5), "set", "reset") & vbCrLf
  610.    strDisplay = strDisplay + "   bit 7 is " & IIf(cGetBitB(bData, 7), "set", "reset") & vbCrLf & vbCrLf
  611.    strDisplay = strDisplay + "Integer value : " & iData & " (" & cToBinary(cMKI(iData)) & ")" & vbCrLf
  612.    strDisplay = strDisplay + "   bit 0 is " & IIf(cGetBitI(iData, 0), "set", "reset") & vbCrLf
  613.    strDisplay = strDisplay + "   bit 3 is " & IIf(cGetBitI(iData, 3), "set", "reset") & vbCrLf
  614.    strDisplay = strDisplay + "   bit 7 is " & IIf(cGetBitI(iData, 7), "set", "reset") & vbCrLf
  615.    strDisplay = strDisplay + "   bit 11 is " & IIf(cGetBitI(iData, 11), "set", "reset") & vbCrLf
  616.    strDisplay = strDisplay + "   bit 15 is " & IIf(cGetBitI(iData, 15), "set", "reset") & vbCrLf & vbCrLf
  617.    strDisplay = strDisplay + "Long value : " & lData & " (" & cToBinary(cMKL(lData)) & ")" & vbCrLf
  618.    strDisplay = strDisplay + "   bit 0 is " & IIf(cGetBitL(lData, 0), "set", "reset") & vbCrLf
  619.    strDisplay = strDisplay + "   bit 5 is " & IIf(cGetBitL(lData, 5), "set", "reset") & vbCrLf
  620.    strDisplay = strDisplay + "   bit 10 is " & IIf(cGetBitL(lData, 10), "set", "reset") & vbCrLf
  621.    strDisplay = strDisplay + "   bit 15 is " & IIf(cGetBitL(lData, 15), "set", "reset") & vbCrLf
  622.    strDisplay = strDisplay + "   bit 20 is " & IIf(cGetBitL(lData, 20), "set", "reset") & vbCrLf & vbCrLf
  623.    strDisplay = strDisplay + "Single value : " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf
  624.    strDisplay = strDisplay + "   bit 0 is " & IIf(cGetBitS(sData, 0), "set", "reset") & vbCrLf
  625.    strDisplay = strDisplay + "   bit 5 is " & IIf(cGetBitS(sData, 5), "set", "reset") & vbCrLf
  626.    strDisplay = strDisplay + "   bit 10 is " & IIf(cGetBitS(sData, 10), "set", "reset") & vbCrLf
  627.    strDisplay = strDisplay + "   bit 15 is " & IIf(cGetBitS(sData, 15), "set", "reset") & vbCrLf
  628.    strDisplay = strDisplay + "   bit 20 is " & IIf(cGetBitS(sData, 20), "set", "reset") & vbCrLf & vbCrLf
  629.    strDisplay = strDisplay + "Double value : " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf
  630.    strDisplay = strDisplay + "   bit 0 is " & IIf(cGetBitD(dData, 0), "set", "reset") & vbCrLf
  631.    strDisplay = strDisplay + "   bit 10 is " & IIf(cGetBitD(dData, 10), "set", "reset") & vbCrLf
  632.    strDisplay = strDisplay + "   bit 20 is " & IIf(cGetBitD(dData, 20), "set", "reset") & vbCrLf
  633.    strDisplay = strDisplay + "   bit 30 is " & IIf(cGetBitD(dData, 30), "set", "reset") & vbCrLf
  634.    strDisplay = strDisplay + "   bit 40 is " & IIf(cGetBitD(dData, 40), "set", "reset") & vbCrLf & vbCrLf
  635.    txt_Result = strDisplay
  636.    'time the function
  637.    TimerHandle = cTimerOpen()
  638.    TimerStartOk = cTimerStart(TimerHandle)
  639.    For i = 1 To Iteration
  640.       intResult = cGetBitI(iData, i)
  641.    Next i
  642.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  643.    TimerCloseOk = cTimerClose(TimerHandle)
  644. End Sub
  645. Private Sub TestSetBitValue()
  646.    Dim intResult        As Integer
  647.    Dim strResult        As String
  648.    Dim strDisplay       As String
  649.    Dim bData            As Byte
  650.    Dim iData            As Integer
  651.    Dim lData            As Long
  652.    Dim sData            As Single
  653.    Dim dData            As Double
  654.    Dim i                As Integer
  655.    intResult = 0
  656.    strResult = ""
  657.    strDisplay = ""
  658.    bData = (Abs(cRndI()) Mod 256)
  659.    iData = Abs(cRndI())
  660.    lData = Abs(cRndL())
  661.    sData = Abs(cRndS())
  662.    dData = Abs(cRndD())
  663.      
  664.    strDisplay = strDisplay + "Byte value : " & bData & " (" & cToBinary(cMKB(bData)) & ")" & vbCrLf
  665.    Call cSetBitB(bData, 0, True)
  666.    strDisplay = strDisplay + "   set bit 0 is " & bData & " (" & cToBinary(cMKB(bData)) & ")" & vbCrLf
  667.    Call cSetBitB(bData, 3, False)
  668.    strDisplay = strDisplay + "   reset bit 3 is " & bData & " (" & cToBinary(cMKB(bData)) & ")" & vbCrLf
  669.    Call cSetBitB(bData, 5, True)
  670.    strDisplay = strDisplay + "   set bit 5 is " & bData & " (" & cToBinary(cMKB(bData)) & ")" & vbCrLf & vbCrLf
  671.    strDisplay = strDisplay + "Integer value : " & iData & " (" & cToBinary(cMKI(iData)) & ")" & vbCrLf
  672.    Call cSetBitI(iData, 3, True)
  673.    strDisplay = strDisplay + "   set bit 3 is " & iData & " (" & cToBinary(cMKI(iData)) & ")" & vbCrLf
  674.    Call cSetBitI(iData, 6, False)
  675.    strDisplay = strDisplay + "   reset bit 6 is " & iData & " (" & cToBinary(cMKI(iData)) & ")" & vbCrLf
  676.    Call cSetBitI(iData, 9, True)
  677.    strDisplay = strDisplay + "   set bit 9 is " & iData & " (" & cToBinary(cMKI(iData)) & ")" & vbCrLf & vbCrLf
  678.    strDisplay = strDisplay + "Long value : " & lData & " (" & cToBinary(cMKL(lData)) & ")" & vbCrLf
  679.    Call cSetBitL(lData, 6, True)
  680.    strDisplay = strDisplay + "   set bit 6 is " & lData & " (" & cToBinary(cMKL(lData)) & ")" & vbCrLf
  681.    Call cSetBitL(lData, 12, False)
  682.    strDisplay = strDisplay + "   reset bit 12 is " & lData & " (" & cToBinary(cMKL(lData)) & ")" & vbCrLf
  683.    Call cSetBitL(lData, 24, True)
  684.    strDisplay = strDisplay + "   set bit 24 is " & lData & " (" & cToBinary(cMKL(lData)) & ")" & vbCrLf & vbCrLf
  685.    strDisplay = strDisplay + "Single value : " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf
  686.    Call cSetBitS(sData, 0, True)
  687.    strDisplay = strDisplay + "   set bit 0 is " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf
  688.    Call cSetBitS(sData, 3, True)
  689.    strDisplay = strDisplay + "   set bit 3 is " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf
  690.    Call cSetBitS(sData, 6, True)
  691.    strDisplay = strDisplay + "   set bit 6 is " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf
  692.    Call cSetBitS(sData, 12, True)
  693.    strDisplay = strDisplay + "   set bit 12 is " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf
  694.    Call cSetBitS(sData, 24, True)
  695.    strDisplay = strDisplay + "   set bit 24 is " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf & vbCrLf
  696.    strDisplay = strDisplay + "Double value : " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf
  697.    Call cSetBitD(dData, 0, False)
  698.    strDisplay = strDisplay + "   reset bit 0 is " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf
  699.    Call cSetBitD(dData, 3, False)
  700.    strDisplay = strDisplay + "   reset bit 3 is " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf
  701.    Call cSetBitD(dData, 12, False)
  702.    strDisplay = strDisplay + "   reset bit 12 is " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf
  703.    Call cSetBitD(dData, 24, False)
  704.    strDisplay = strDisplay + "   reset bit 24 is " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf
  705.    Call cSetBitD(dData, 48, False)
  706.    strDisplay = strDisplay + "   reset bit 48 is " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf & vbCrLf
  707.    txt_Result = strDisplay
  708.    'time the function
  709.    TimerHandle = cTimerOpen()
  710.    TimerStartOk = cTimerStart(TimerHandle)
  711.    For i = 1 To Iteration
  712.       Call cSetBitI(iData, 0, True)
  713.    Next i
  714.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  715.    TimerCloseOk = cTimerClose(TimerHandle)
  716. End Sub
  717. Private Sub TestB2I()
  718.    Dim lngResult        As Long
  719.    Dim strResult        As String
  720.    Dim strDisplay       As String
  721.    Dim i                As Integer
  722.    Dim i1               As String
  723.    Dim i2               As String
  724.    Dim l1               As String
  725.    Dim l2               As String
  726.    i1 = "1010101010101010"
  727.    i2 = "0101010101010101"
  728.    l1 = "10101010101010101010101010101010"
  729.    l2 = "01010101010101010101010101010101"
  730.    lngResult = 0
  731.    strResult = ""
  732.    strDisplay = ""
  733.      
  734.    strDisplay = strDisplay & "B2I of " & i1 & " is " & cB2I(i1) & vbCrLf
  735.    strDisplay = strDisplay & "B2I of " & i2 & " is " & cB2I(i2) & vbCrLf & vbCrLf
  736.    strDisplay = strDisplay & "I2B of " & cB2I(i1) & " is " & cI2B(cB2I(i1)) & vbCrLf
  737.    strDisplay = strDisplay & "I2B of " & cB2I(i2) & " is " & cI2B(cB2I(i2)) & vbCrLf & vbCrLf
  738.    strDisplay = strDisplay & "B2L of " & l1 & " is " & cB2L(l1) & vbCrLf
  739.    strDisplay = strDisplay & "B2L of " & l2 & " is " & cB2L(l2) & vbCrLf & vbCrLf
  740.    strDisplay = strDisplay & "L2B of " & cB2L(l1) & " is " & cL2B(cB2L(l1)) & vbCrLf
  741.    strDisplay = strDisplay & "L2B of " & cB2L(l2) & " is " & cL2B(cB2L(l2)) & vbCrLf & vbCrLf
  742.    txt_Result = strDisplay
  743.    'time the function
  744.    TimerHandle = cTimerOpen()
  745.    TimerStartOk = cTimerStart(TimerHandle)
  746.    For i = 1 To Iteration
  747.       strResult = cB2I(12345)
  748.    Next i
  749.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  750.    TimerCloseOk = cTimerClose(TimerHandle)
  751. End Sub
  752.